package cn.com.chec.en.controller.admin;

import cn.com.chec.en.model.domain.UserInfo;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping({ "/admin/index" })
public class LoginAdminController {
	protected static final Logger logger = Logger
			.getLogger(LoginAdminController.class);

	@Resource
	private Map<String, Object> environment;

	@RequestMapping(value = { "/roleList" }, method = { org.springframework.web.bind.annotation.RequestMethod.GET })
	public ModelAndView roleList(HttpServletRequest request,
			HttpServletResponse response, ModelMap map) throws Exception {
		UserInfo userInfoSession = (UserInfo) request.getSession()
				.getAttribute("systemUserInfo");
		map.put("userInfoSession", userInfoSession);

		ModelAndView mav = new ModelAndView("admin/framest/roleList");
		map.putAll(this.environment);
		mav.addAllObjects(map);
		return mav;
	}

	@RequestMapping(value = { "/left" }, method = { org.springframework.web.bind.annotation.RequestMethod.GET })
	public ModelAndView left(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return new ModelAndView("admin/framest/left");
	}

	@RequestMapping(value = { "/right" }, method = { org.springframework.web.bind.annotation.RequestMethod.GET })
	public ModelAndView right(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return new ModelAndView("admin/framest/right");
	}

	@RequestMapping(value = { "/end" }, method = { org.springframework.web.bind.annotation.RequestMethod.GET })
	public ModelAndView end(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return new ModelAndView("admin/framest/end");
	}

	@RequestMapping(value = { "/split" }, method = { org.springframework.web.bind.annotation.RequestMethod.GET })
	public ModelAndView split(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return new ModelAndView("admin/framest/split");
	}

	@RequestMapping(value = { "/logout" }, method = { org.springframework.web.bind.annotation.RequestMethod.GET })
	public ModelAndView logout(HttpServletRequest request,
			HttpServletResponse response, HttpSession session) throws Exception {
		session.removeAttribute("systemUserInfo");
		session.invalidate();
		return new ModelAndView("redirect:/logon");
	}
}